<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Records &middot; Kursadarbs</title>
<link href="/j2kursad/resources/css/bootstrap.css" rel="stylesheet">
<link href="/j2kursad/resources/css/bootstrap-responsive.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>

<div class="container">
<div class="page-header">
  <h1>Kursadarbs</h1>
</div>

	<c:url var="editImgUrl" value="/resources/img/edt.gif" /> <!-- Image refference http://www.aspneticons.com/ -->
	<c:url var="deleteImgUrl" value="/resources/img/del.gif" /> <!-- Image refference http://www.aspneticons.com/ -->
	<c:url var="addUrl" value="/karlis/record/add" />

<div class="btn-group">
  <button class="btn" onclick="window.location='http://localhost:8081/j2kursad/karlis/auth/logout';">Logout</button>
  <a href="${addUrl}"><button class="btn">Create new record</button></a>
  <a href="<c:url value="/karlis/download/xls" />" ><button class="btn">Export file</button></a>
</div>

<table class="table table-bordered">
<thead>
  <tr>
   <!-- <th>Id</th> -->
   <th>Name</th>
   <th>Address</th>
   <th>Phone</th>
   <th>Edit</th>
   <th>Delete</th>
  </tr>
</thead>
 <c:forEach items="${warehouses}" var="warehouse">
  <c:url var="editUrl" value="/karlis/record/edit?id=${warehouse.id}" />
  <c:url var="deleteUrl" value="/karlis/record/delete?id=${warehouse.id}" />
   
  <c:if test="${!empty warehouse.items}">
   <c:forEach items="${warehouse.items}" var="item">
   <tbody></tbody>
   <tr>
   <!--  <td><c:out value="${warehouse.id}" /></td> -->
    <td><c:out value="${warehouse.name}" /></td>
    <td><c:out value="${warehouse.address}" /></td>
    <td><c:out value="${warehouse.manager}" /></td>
    <td><a href="${editUrl}"><img src="${editImgUrl}"></img></a></td>
    <td><a href="${deleteUrl}"><img src="${deleteImgUrl}"></img></a></td>
     </tr>
  <!--   <td><c:out value="${item.name}" /></td>
    <td><c:out value="${item.number}" /></td>
    <c:url var="addCcUrl" value="/karlis/item/add?id=${warehouse.id}" />
    <c:url var="editCcUrl" value="/karlis/item/edit?pid=${warehouse.id}&cid=${item.id}" />
    <c:url var="deleteCcUrl" value="/karlis/item/delete?id=${item.id}" />
    <td><a href="${addCcUrl}">+</a></td>
    <td><a href="${editCcUrl}"><img src="${editImgUrl}"></img></a></td>
    <td><a href="${deleteCcUrl}"><img src="${deleteImgUrl}"></img></a></td>
    -->
   </c:forEach>
  </c:if>
  
  <c:if test="${empty warehouse.items}">
   <tr>
   <!--  <td><c:out value="${warehouse.id}" /></td> -->
    <td><c:out value="${warehouse.name}" /></td>
    <td><c:out value="${warehouse.address}" /></td>
    <td><c:out value="${warehouse.manager}" /></td>
    <td><a href="${editUrl}"><img src="${editImgUrl}"></img></a></td>
    <td><a href="${deleteUrl}"><img src="${deleteImgUrl}"></img></a></td>
    
   <!--   
    <td>N/A</td>
    <td>N/A</td>
    <c:url var="addCcUrl" value="/karlis/item/add?id=${warehouse.id}" />
    <td><a href="${addCcUrl}">+</a></td>
    <td></td>
    <td></td> -->
   
  </c:if>
 
 </c:forEach>
 </tbody>
 </table>

 
<c:if test="${empty warehouses}">
 No records found. 
</c:if>
</div>
 
</body>
</html>